package com.xishu.service;

import net.sf.json.JsonConfig;
import net.sf.json.processors.JsonValueProcessor;

public class JsonNumberValueProcessor implements JsonValueProcessor {
    @Override
    public Object processArrayValue(Object o, JsonConfig jsonConfig) {
        return process(o);
    }

    @Override
    public Object processObjectValue(String s, Object o, JsonConfig jsonConfig) {
        return process(o);
    }

    private Object process(Object value) {
        if (value instanceof Long) {

            if (value == null) {
                return "";
            }
        }

        if (value instanceof Integer) {
            if (value == null) {
                return "";
            }
        }

        if (value instanceof Double) {
            if (value == null) {
                return "";
            }
        }

        if (value instanceof Float) {
            if (value == null) {
                return "";
            }
        }

        return value == null ? "" : value;
    }

}
